<?php
require_once ('./class/H.class.php');
require_once ('./class/database.class.php');
_repair();
function _repair($p = 1,$pageSz = 50){
    global $dbm;
    //cid=4 励志，cid=1 唯美
    $listData = $dbm->select('tb_content',['id','desc'],['desc[~]'=>"cads","ORDER"=>['id'=>"ASC"],'LIMIT' => [($p-1)*$pageSz,$pageSz]]);
    if(count($listData) == 0){
        echo "already completes...".chr(10);
        return;
    }
    //H::p($listData,1);
    foreach($listData as $k => $v){
      //  echo str_replace('cads();',"",$v['desc']).chr(10);
        $dbm->update('tb_content',['desc'=>str_replace('cads();',"",$v['desc'])],['id'=>$v['id']]);
        echo $v['id']."-repair success".chr(10);
    }
    sleep(1);
    _repair($p + 1,$pageSz);
}
